﻿/*
 * Author: Kasper van Voorst
 * */

using System;
using System.IO;
using System.Linq;


namespace LibraryCS {
    public static class MaskReader {
        public static int[] convertToMask(string path) {
            try {
                using (StreamReader sr = new StreamReader(path)) {
                    string line;
                    string theFile = "";
                    //Converting the file to a single string
                    while ((line = sr.ReadLine()) != null) {
                        theFile += line;
                    }
                    //Parsing the string to an array of integers, using the comma as a delimiter.
                    int[] mask = theFile.Split(',').Select(x => int.Parse(x)).ToArray();
                    return mask;
                }
            } catch (Exception e) {
                Console.WriteLine("The file could not be read:");
                Console.WriteLine(e.Message);
            }
            return null;
        }
    }
}
